package linuxbox.common.taglib;

import java.io.*;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
import javax.servlet.http.*;
import java.util.*;

import linuxbox.BoxStatic;
/**
 * This class displays a Month list in the SELECT tag. 
 */
public class DayList extends TagSupport 
{
	protected boolean allowNull = false;
	protected int selected = -1;
	
	public int doStartTag() throws JspException 
	{
		try 
		{
			JspWriter out = pageContext.getOut();

			if ( allowNull )
			{
			  out.print("<option value=-1>Day</option>");
			}
      for(int i = 1; i <= 31; i++)
      {
        out.print("<option value=\""+i+"\"");
        if ( i == selected)
          out.print(" selected ");
        out.print(">"+i+"</option>");
      }

			out.flush();
		} 
		catch(Exception e) 
		{
			e.printStackTrace();
			throw new JspException(e.getMessage());
		}
		
		return SKIP_BODY;
	}

	public void setAllownull(String aValue) 
	{
		allowNull = new Boolean(aValue).booleanValue();
	}

	public void setSelected(int aValue) 
	{
		selected = aValue;
	}
}
